package com.scott.ch060;

import redis.clients.jedis.Jedis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 黄后林
 * @version 1.0
 * @note
 * @date 2022-03-25 14:37:05
 */
public class RedisHashDemo2 {

    public static void main(String[] args) {
        Jedis jedis = new Jedis("192.168.88.129", 6379);

        Map<String,String> map = new HashMap<>();
        map.put("name","scott");
        map.put("age","39");
        map.put("salary","29500");

        jedis.del("teacher:10010");

        //1次设置多个值
        jedis.hmset("teacher:10010",map);

        //1次拿2个属性
        List<String> two = jedis.hmget("teacher:10010", "name", "salary");
        System.out.println("two="+two);

        //拿所有的值
        Map<String, String> all = jedis.hgetAll("teacher:10010");
        System.out.println("all="+all);
        jedis.close();
    }
}
